iT邦幫忙

0

PYTHON 學習筆記 008

  • 分享至 

  • xImage
  •  

if statement

def max_num(num1,num2,num3):
    print('this is max_num1')
    return(max(num1,num2,num3))
print(max_num(2,3,108))

def max_num(num1,num2,num3):
    print('this is max num2')
    if num1>=num2 and num1>=num3:
        return num1
    elif num2>=num1 and num2>=num3:
        return num2
    else:
        return num3
print(max_num(2,111,111111))

https://ithelp.ithome.com.tw/upload/images/20221225/20156136yOvfQXf8kY.jpg

進階計算機(可加減乘除運算)

num1 = float(input("請輸入第一個數字: "))
op = input("請輸入運算符號: ")
num2 = float(input("請輸入第二個數字: "))

if op=="+":
    print(num1+num2)
elif op=="-":
    print(num1-num2)
elif op=="*":
    print(num1*num2)
elif op=="/":
    print(num1/num2)
else:
    priint("不支援的運算")

https://ithelp.ithome.com.tw/upload/images/20221225/20156136VptEz1M2NN.jpg
https://ithelp.ithome.com.tw/upload/images/20221225/20156136FBI8HYXi7U.jpg


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言